package com.zhongfl.crm.service.impl;

import com.zhongfl.crm.mapper.LxAttachmentMapper;
import com.zhongfl.crm.model.LxAttachment;
import com.zhongfl.crm.service.LxAttachmentService;
import org.springframework.stereotype.Service;
import tech.heptagram.staff.cas.common.AssertUtils;

import javax.annotation.Resource;
import java.util.List;

/**
 * 励销附件 服务实现类
 *
 * @author tiantian
 * @date 2018/9/21 15:37
 */
@Service
public class LxAttachmentServiceImpl implements LxAttachmentService {

    @Resource
    private LxAttachmentMapper lxAttachmentMapper;

    @Override
    public void deleteById(Long id) {
        AssertUtils.notNull(id,"附件ID为空！");
        lxAttachmentMapper.deleteById(id);
    }

    @Override
    public void insert(LxAttachment record) {
        AssertUtils.notNull(record,"附件对象为空！");
        lxAttachmentMapper.insertSelective(record);
    }

    @Override
    public LxAttachment findById(Long id) {
        AssertUtils.notNull(id,"附件ID为空！");
        return lxAttachmentMapper.selectById(id);
    }

    @Override
    public void updateById(LxAttachment record) {
        AssertUtils.notNull(record,"附件对象为空！");
        AssertUtils.notNull(record.getId(),"附件ID为空！");
        lxAttachmentMapper.updateByIdSelective(record);
    }

    @Override
    public List<LxAttachment> findByRevisitLogId(Long revisitLogId) {
        return lxAttachmentMapper.selectLxAttachmentByParentRevisitLogId(revisitLogId);
    }
}
